#-*- coding: big5 -*-
from modelRepository import modelRepository
class ViewBook:
    def __init__(self):
       self.intIndent=0
       
    def showBookComponent(self,lstBookComponent):
       if not lstBookComponent: return
       for bookComponent in lstBookComponent:
           if bookComponent.isLeaf():
               print ' '*self.intIndent+bookComponent.strText
           else:
               if bookComponent.strText:
                   print ' '*self.intIndent+bookComponent.strText
               self.intIndent+=4
               self.showBookComponent(bookComponent.lstBookComponent)
               self.intIndent-=4
               
    def show(self):
        modelBook=modelRepository.getModelBook()
        print 'Book Title:%s'%modelBook.strText
        print 'Author:%s'%modelBook.strAuthor
        self.showBookComponent(modelBook.lstBookComponent)
       
    def showDic(self,dic):
        for i in dic.keys():
            print 'key:%s'%i
            print 'value:%s'%dic[i]
            print 'strText:%s'%dic[i].strText

viewBook=ViewBook()
